// src/router/index.ts
 
import { createRouter, createWebHistory,createWebHashHistory } from 'vue-router';


 
const routes = [
  {
    path: '/',
    name: 'Home',
    component:  () => import('@/views/home/index.vue') ,
  },
  {
    path: '/category/:type',
    name: 'category',
    component:  () => import('@/views/category/index.vue') ,
  },
  {
    path: '/detail/:type/:name/:id',
    name: 'detail',
    component: () => import('@/views/detail/index.vue') ,
  },
  {
    path: '/aboutUs',
    name: 'aboutUs',
    component: () => import('@/views/aboutUs/index.vue') ,
  },
  {
    path: '/term_of_us',
    name: 'term_of_us',
    component: () => import('@/views/term_of_us/index.vue') ,
  },
  {
    path: '/privacy_policy',
    name: 'privacy_policy',
    component: () => import('@/views/privacy_policy/index.vue') ,
  },
  {
    path: '/search/:keyWords',
    name: 'search',
    component: () => import('@/views/search/index.vue') ,
  },
  {
    path: '/contactUs',
    name: 'contactUs',
    component: () => import('@/views/contactUs/index.vue') ,
  },
];
 
const router = createRouter({
  history: createWebHashHistory(''),
  routes,
});
// histroym模式得加news
// const router = createRouter({
//   history: createWebHistory('/news/'),
//   routes,
// });
 
// 在这里添加路由的导航守卫
router.beforeEach((to, from, next) => {  
    console.log('Navigating to:', to.path);
    next();
  });
 
export default router;